IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetSponsor]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[GetSponsor]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

/******************************************************************
*
* Name:			GetSponsor
* Purpose:		Retrieves a single sponsor based on the id supplied
*
* PARAMETERS
* Name    				Description					
* -------------  		-------------------------------------------
* @sponsorId			Sponsor Id.	(REQUIRED)  
*
***********************************************************************/

CREATE Procedure [dbo].[GetSponsor] (
		@sponsorId				INTEGER
)
AS

BEGIN

	SET NOCOUNT ON

	SELECT	s.Id as SponsorId,
			s.Name, 
			s.ShortName, 
			s.Description, 
			t.Name as SponsorType,
			s.DateCreated,
			s.RexSponsorId,		
			s.InfoEdSponCode,
			s.PSCustCode,
            s.AdmSponsorTypeId,
			asr.Rate as ChargeRate
	FROM	AdmSponsor s
	INNER JOIN AdmSponsorType T ON
	s.AdmSponsorTypeId = t.Id
	Inner Join AdmSponsorRate asr
	on asr.Id = T.AdmSponsorRateId
	WHERE	s.Id = @sponsorId

END
GO
